home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 May / PCWorld_2007-05_cd.bin / komunikace / alleycode / alleycodesetup.exe / {app} / PHP / pregmatch.php < prev    next >
Encoding:
PHP Script  |  2003-11-08  |  284 b   |  9 lines

  1. <?php
  2. // get host name from URL
  3. preg_match("/^(http:\/\/)?([^\/]+)/i", "http://www.alleycode.com/index.htm", $matches);
  4. $host = $matches[2];
  5.  
  6. // get last two segments of host name
  7. preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
  8. echo "domain name is: {$matches[0]}\n";
  9. ?>